package servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class calculaIMC
 */
public class calculaIMC extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
	

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int peso = Integer.parseInt(request.getParameter("peso"));
		int altura = Integer.parseInt(request.getParameter("altura"));
		int resultado =  (altura*2)/peso;
		
		HttpSession session = request.getSession();
		session.setAttribute("peso", peso);
		session.setAttribute("altura", altura);
		session.setAttribute("resultado", resultado);
		
		RequestDispatcher rd =  request.getRequestDispatcher("Exibir.jsp");
		rd.forward(request, response);
	}

}
